// 封装频道下拉框

import { Select } from 'antd';
import { channelListApi } from 'api/channel';
import React, { useEffect, useState } from 'react';
const { Option } = Select;

export default function Channel(props) {
  const [channelList, setchannelList] = useState([]);
  // 封装频道列表请求
  const getChannelList = async () => {
    const res = await channelListApi();
    setchannelList(res.data.channels);
  };
  useEffect(() => {
    getChannelList();
  }, []);
  return (
    <Select style={{ width: 120 }} {...props}>
      {channelList.map((item) => {
        return (
          <Option key={item.id} value={item.id}>
            {item.name}
          </Option>
        );
      })}
    </Select>
  );
}
